<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/21
 * Time: 13:02
 */
include "../classes/logincheck.php";
include '../classes/conn.php';
if(islogin()!='stu_login'){
    die('error');
}

$class=$_POST['class'];
$title=$_POST['title'];
$detail=$_POST['detail'];
$time=$time=date('Y-m-d H:i:s');

//查询教师
$query_t="select teacher from class where num='{$class}'";
$res=mysql_query($query_t);
$teacher=mysql_fetch_assoc($res)['teacher'];

$query="insert into leavemessage (student, class,teacher, title, detail, time) 
values ('{$_SESSION['stu_num']}','{$class}','{$teacher}','{$title}','{$detail}','{$time}')";

$res=mysql_query($query);
if($res){
    echo '1';
}
else echo '0';